fix(atomic): When a citation title is null or undefined, there's a unhandled exception#6801
Merged
erocheleau merged 5 commits intomainfrom Jan 12, 2026
Merged
fix(atomic): When a citation title is null or undefined, there's a unhandled exception#6801erocheleau merged 5 commits intomainfrom
erocheleau merged 5 commits intomainfrom
Conversation
SimonMilord
reviewed
Dec 12, 2025
Contributor
SimonMilord
left a comment
There was a problem hiding this comment.
looks fine but you sure we can't just mock a citation object with title=null and spy on an error being thrown?
Were you able to reproduce it and test the fix manually?
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes an unhandled exception that occurs when a citation title is null or undefined in generated answers. The fix uses the nullish coalescing operator (??) to safely handle these cases before calling .trim() on the title.
Changes:
- Added null/undefined safety check using nullish coalescing operator in two locations
- Added test coverage for the missing title scenario
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
packages/atomic/src/components/common/generated-answer/generated-answer-utils.ts |
Added nullish coalescing operator to safely handle null/undefined titles before trimming |
packages/atomic/src/components/common/generated-answer/generated-answer-common.tsx |
Applied the same null safety fix to the getCitation method |
packages/atomic/src/components/common/generated-answer/generated-answer-utils.spec.ts |
Added test case to verify fallback title is applied when title is missing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/atomic/src/components/common/generated-answer/generated-answer-utils.spec.ts
Show resolved
Hide resolved
packages/atomic/src/components/common/generated-answer/generated-answer-common.tsx
Show resolved
Hide resolved
SimonMilord
approved these changes
Jan 12, 2026
mmitiche
approved these changes
Jan 12, 2026
packages/atomic/src/components/common/generated-answer/generated-answer-utils.spec.ts
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SFINT-6544
When the citation title is
nullorundefined, we try to call.trim()on it and it throws an exception preventing the correct rendering of the generated answer.I fixed it both for the "deprecated" `generated-answer-common file and the newly migrated generated-answer-utils.
For the function in the generated-answer-utils file, I was able to add a unit test to cover this case.
For the -common code (which I think is no longer used by us, but kept for non-breaking changes?). I tested it manually with mocking a response from CRGA with a citation that would have no title, it correctly defaults to the localized string "No Title".